﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Commander.DataLayer {
  public interface IDomainConfig {
    string ConnectionString { get; }
  }

  public class DomainConfig : IDomainConfig {
    const string ConnectionStringKey = "ConnectionString";
    const string DomainAssemblyKey = "DomainAssembly";

    static DomainConfig instance;
    public static DomainConfig Instance {
      get {
        if (instance == null) instance = new DomainConfig();
        return instance;
      }
    }

    public string ConnectionString {
      get {
        return GetSetting(ConnectionStringKey);
      }
    }

    public string DomainAssembly {
      get {
        return GetSetting(DomainAssemblyKey);
      }
    }

    string GetSetting(string key) {
      if (!string.IsNullOrEmpty(key)) {
        return System.Configuration.ConfigurationManager.AppSettings[key];
      }
      return string.Empty;
    }
  }

}
